package com.huadao.cart_ccs.greendao.entity;

import android.content.Context;

import com.huadao.cart_ccs.R;
import com.huadao.cart_ccs.exception.ExceptionCode;
import com.huadao.cart_ccs.main.CartApplication;

import org.greenrobot.greendao.annotation.Entity;
import org.greenrobot.greendao.annotation.Generated;
import org.greenrobot.greendao.annotation.Id;

import java.util.Date;

@Entity
public class ExceptionInfo {
    @Id
    private Long id;
    private Date date;
    private long ProjectId;
    private long stageId;
    //错误码
    private byte code;
    private String message;
    private int type;

    @Generated(hash = 1637840596)
    public ExceptionInfo(Long id, Date date, long ProjectId, long stageId,
            byte code, String message, int type) {
        this.id = id;
        this.date = date;
        this.ProjectId = ProjectId;
        this.stageId = stageId;
        this.code = code;
        this.message = message;
        this.type = type;
    }
    @Generated(hash = 841014831)
    public ExceptionInfo() {
    }
    public Long getId() {
        return this.id;
    }
    public void setId(Long id) {
        this.id = id;
    }
    public Date getDate() {
        return this.date;
    }
    public void setDate(Date date) {
        this.date = date;
    }
    public long getProjectId() {
        return this.ProjectId;
    }
    public void setProjectId(long ProjectId) {
        this.ProjectId = ProjectId;
    }
    public long getStageId() {
        return this.stageId;
    }
    public void setStageId(long stageId) {
        this.stageId = stageId;
    }
    public byte getCode() {
        return this.code;
    }
    public void setCode(byte code) {
        this.code = code;
    }
    public String getMessage() {
        return this.message;
    }
    public void setMessage(String message) {
        this.message = message;
    }
    public int getType() {
        return this.type;
    }
    public void setType(int type) {
        this.type = type;
    }

    public String getCodeString(){
        String str;
        Context context= CartApplication.getInstance();
        switch (code){
            case ExceptionCode.O2:
                str=context.getString(R.string.O2);
                break;
            case ExceptionCode.CO2:
                str=context.getString(R.string.CO2);
                break;
            case ExceptionCode.TEMPERATURE:
                str=context.getString(R.string.temperature);
                break;
            case ExceptionCode.WEIGHT:
                str=context.getString(R.string.weight);
                break;
            case ExceptionCode.SERIALPORT:
                str=context.getString(R.string.serial_port);
                break;
            case ExceptionCode.unpack:
                str=context.getString(R.string.unpack);
                break;
            case ExceptionCode.HEAD:
                str=context.getString(R.string.protocol_head);
                break;
            case ExceptionCode.LENGTH:
                str=context.getString(R.string.protocol_length);
                break;
            case ExceptionCode.AGENT_CODE:
                str=context.getString(R.string.protocol_agent);
                break;
            case ExceptionCode.MAC:
                str=context.getString(R.string.protocol_mac);
                break;
            case ExceptionCode.DEVICE_TYPE:
                str=context.getString(R.string.protocol_devicetype);
                break;
            case ExceptionCode.COMMOND_WORD:
                str=context.getString(R.string.protocol_commandword);
                break;
            case ExceptionCode.MODULAR_ORDER:
                str=context.getString(R.string.protocol_modularorder);
                break;
            case ExceptionCode.ORDER_CONTENT:
                str=context.getString(R.string.protocol_ordercontent);
                break;
            case ExceptionCode.CHECKSUM:
                str=context.getString(R.string.protocol_checksum);
                break;
            case ExceptionCode.TAIL:
                str=context.getString(R.string.protocol_tail);
                break;
            case ExceptionCode.crash:
                str=context.getString(R.string.systemerror);
                break;
            default:
                str=context.getString(R.string.unknow);
                break;
        }
        return str;
    }
}
